package com.lili.collection.restful.enums;

import cn.hutool.core.text.CharSequenceUtil;
import lombok.Getter;

/**
 * 接口类型
 *
 * @author: lili
 * @since: 2023/3/9 15:25
 */
public enum InterfaceType {

    /**
     * Restful接口类型
     */
    RESTFUL("RESTful"),
    /**
     * 税务云服务集成平台SDK
     */
    YFWJCPT_SDK("YfwjcptSdk"),
    /**
     * Webservice接口类型
     */
    WEBSERVICE("Webservice");

    @Getter
    private final String code;

    InterfaceType(String code) {
        this.code = code;
    }

    /**
     * 获取接口类型枚举，忽略大小写
     * @param code code
     * @return 接口类型枚举
     */
    public static InterfaceType codeOf(String code) {
        for (InterfaceType value : InterfaceType.values()) {
            if (CharSequenceUtil.equalsIgnoreCase(value.getCode(), code)) {
                return value;
            }
        }
        throw new IllegalArgumentException("暂不支持该接口类型");
    }
}

